home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9453 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.4 KB

  1. Path: risc.sps.mot.com!not-for-mail
  2. From: moss@risc.sps.mot.com (Matthew Moss)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Fahrenheight to Celsius?
  5. Date: 1 Mar 1996 14:01:41 -0600
  6. Organization: Motorola, Inc. -- Austin,TX
  7. Message-ID: <4h7l35INN7oe@hood.sps.mot.com>
  8. References: <4fvthq$2bl@newserv.agcs.com> <1996Feb26.060213.23285@lafn.org> <4h1v08$eks@druid.borland.com> <xmsb.825531341@shadow>
  9. NNTP-Posting-Host: hood.sps.mot.com
  10.  
  11. In article <xmsb.825531341@shadow>,
  12. Maurice S. Barnum <xmsb@shadow.borland.com> wrote:
  13. >pete@borland.com (Pete Becker) writes:
  14. >
  15. >>In article <1996Feb26.060213.23285@lafn.org>, an234@lafn.org says...
  16. >>>
  17. >>>F = C*(9/5) +32
  18. >>>C = (F-32)*(5/9)
  19. >
  20. >>He was better off without this answer, which is wrong.
  21. >
  22. >    my favorite conversion equations, which i learned from
  23. >    reading an article by isaac asimov, is not only simpler,
  24. >    but avoids having to worry as much about the "obvious"
  25. >    problem when written as C++:
  26. >
  27. >F = (C + 40) / 1.8 - 40
  28. >C = (F + 40) * 1.8 - 40
  29. >
  30. >    for reasons i've never understood, these are not the
  31. >    equations one will find in most books.
  32. >
  33. > --xmsb
  34. > xmsb@borland.com
  35.  
  36. Ummm.... the first answer is the correct set of equations. The second
  37. set of equations is nice-looking but WRONG. To prove this point, use
  38. simple algebra and two well known temperature points, freezing and
  39. boiling.
  40.  
  41.     freezing (F,C) = ( 32,   0)
  42.     boiling  (F,C) = (212, 100)
  43.  
  44. It's a linear function  F = mC + b. Determine the slope m = (F2-F1)/(C2-C1)
  45. So m = (212-32)/(100-0) = 9/5 = 1.8
  46.  
  47. So far:  F = 1.8C + b
  48. Plug in (32, 0)
  49.     32 = 1.8(0) + b
  50.     32 = 0 + b
  51.     b = 32
  52.  
  53. So:
  54.     F = (1.8 * C) + 32
  55. and
  56.     C = (F - 32) / 1.8
  57.  
  58. These are the same as the first answer. The second answer is *almost*
  59. correct.... take the two above derived equations and perform some algebra,
  60. you'll get:
  61.  
  62.     F = (C + 40) * 1.8 - 40
  63.     C = (F + 40) / 1.8 - 40
  64.  
  65. You got the multiplication and division operations switched. Maybe it was
  66. a typo in the article.... They look nice, but most things that go into
  67. the books are usually brought to "simplest terms", not necessary the easiest
  68. to understand. Simplest terms agrees with the traditional formulas. Even
  69. the traditional ones would be more efficient on a computer (in a strict
  70. sense) since it has one less add/substract operation to be done.
  71. -- 
  72. Matthew D Moss                                         RISC Software, Motorola
  73. moss@risc.sps.mot.com                              http://www.mot.com/PowerPC/
  74.